/**
 * There are <a href="https://www.hdzhx.com">邯郸智讯</a> code generation
 */
package com.boxin.ims.modules.wechat.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.persistence.BaseEntity;
import com.thinkgem.jeesite.common.utils.excel.annotation.ExcelField;
import com.thinkgem.jeesite.common.utils.excel.fieldtype.RoleListType;
import com.thinkgem.jeesite.modules.sys.entity.Role;
import com.thinkgem.jeesite.modules.sys.entity.User;

/**
 * 用户业务服务定义类Entity
 * 
 * @author Jakemanse
 * @version 2013-09-27
 */
@Entity
@Table(name = "wp_user_business")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class UserBusiness extends BaseEntity {

	private static final long serialVersionUID = 1L;
	private Long id; 				// 编号
	private User user; 				// 用户
	private String name; 			// 名称
	private String alias; 			// 别名
	private String content; 		// 回复内容
	private BusinessConfig businessConfig; 	// 用户业务服务配置类 (优惠券,签到，积分等)
	private Date createTime; 		// 创建日期
	private String delFlag; 		// 删除标记（0：正常；1：删除）
	private String msgType;			//回复类型  : text,news,vedio
	private String picName;			//回复的图片名称
	private String picTitle;		//图片标题
	private String picDescription;	//图片描述
	private String remarks; 		// 备注

	private List<BusinessConfig> businessConfigList = Lists.newArrayList(); // 服务列表

	private String temp; 			// 临时变量

	public UserBusiness() {
		this.createTime = new Date();
		this.delFlag = DEL_FLAG_NORMAL;
	}

	public UserBusiness(Long id) {
		this();
		this.id = id;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
	// "seq_wechat_userBusiness")
	// @SequenceGenerator(name = "seq_wechat_userBusiness", sequenceName =
	// "seq_wechat_userBusiness")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name = "user_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Length(min = 1, max = 200)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Length(min = 0, max = 255)
	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	@NotNull
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Length(min = 1, max = 1)
	public String getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(String delFlag) {
		this.delFlag = delFlag;
	}

	@ManyToOne
	@JoinColumn(name = "business_config_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public BusinessConfig getBusinessConfig() {
		return businessConfig;
	}

	public void setBusinessConfig(BusinessConfig businessConfig) {
		this.businessConfig = businessConfig;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Transient
	public String getTemp() {
		return temp;
	}

	public void setTemp(String temp) {
		this.temp = temp;
	}

	public String getAlias() {
		return alias;
	}

	public void setAlias(String alias) {
		this.alias = alias;
	}

	
	
 

	public String getMsgType() {
		return msgType;
	}

	public void setMsgType(String msgType) {
		this.msgType = msgType;
	}

	public String getPicName() {
		return picName;
	}

	public void setPicName(String picName) {
		this.picName = picName;
	}

	public String getPicTitle() {
		return picTitle;
	}

	public void setPicTitle(String picTitle) {
		this.picTitle = picTitle;
	}

	public String getPicDescription() {
		return picDescription;
	}

	public void setPicDescription(String picDescription) {
		this.picDescription = picDescription;
	}


	public void setBusinessConfigList(List<BusinessConfig> businessConfigList) {
		this.businessConfigList = businessConfigList;
	}

	@Transient
	public List<Long> getBusinessConfigIdList() {
		List<Long> businessConfigIdList = Lists.newArrayList();
		for (BusinessConfig config : businessConfigList) {
			businessConfigIdList.add(config.getId());
		}
		return businessConfigIdList;
	}

	@Transient
	public void setBusinessConfigIdList(List<Long> businessConfigIdList) {
		businessConfigList = Lists.newArrayList();
		for (Long configId : businessConfigIdList) {
			BusinessConfig config = new BusinessConfig();
			config.setId(configId);
			businessConfigList.add(config);
		}
	}

	
	
	
	
	
	
	
	

}
